import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
// import {baseUrl} from "../request/https.js"
const baseUrl = 'https://lawyer.yic3.cn/'
const store = new Vuex.Store({
	state: {
		//公共的变量，这里的变量不能随便修改，只能通过触发mutations的方法才能改变
		saveAllList: {},
		userInfo: {},
		configShow:false
	
	},
	mutations: {
		//相当于同步的操作
		updateData(state, data) {
			state.saveAllList = data
		},
		editConfig(state, data) {
			state.configShow = data
		},
		updateUserInfo(state, data) {
			uni.setStorageSync('userInfo', data)
			state.userInfo = data
		},
	
	},
	actions: {
		async getUserInfo({
			commit
		}) {
			await uni.$api.getUserInfo().then(async res => {
				console.log(res);
				if (res.data.code == 200) {
					await commit('updateUserInfo', res.data.result.userInfo)
					await commit('updateData', res.data.result.sysAllDictItems)
				}
			})
		},
	}
})
export default store